<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
    <style>
        .sxs-enter-active {
            animation: aaa 0.5s;
        }

        .sxs-leave-active {
            animation: aaa 0.5s reverse;
        }

        @keyframes aaa {
            0% {
                opacity: 0;
                transform: translateX(100px);
            }

            100% {
                opacity: 1;
                transform: translateX(0px);
            }
        }
    </style>
</head>

<body>
    <div id="app">
        <input type="text" v-model="str" ref="input"><button @click="add">增加</button>
        <transition-group tag="ul" name="sxs">
            <li v-for="(item, index) in list" :key="item">{{item}} <button @click="remove(index)">remove</button>
            </li>
        </transition-group>
        <div v-if="list.length === 0">列表不存在数据...</div>
    </div>

    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    list: [],
                    str: ''
                }
            },
            methods: {
                add() {
                    this.list.push(this.str)
                    this.str = ''
                    this.$refs.input.focus()
                },
                remove(index) {
                    this.list.splice(index, 1)
                }
            }
        })
    </script>
</body>

</html>